import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_app/Contact/AddContact2.dart';

class AddContact extends StatefulWidget {
  AddContactWidget createState() => new AddContactWidget();
}

class AddContactWidget extends State<AddContact> {
  TextEditingController textEditingController = new TextEditingController();
  bool is_visible=false;
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title:Container(
          padding: EdgeInsets.fromLTRB(0, 10.0, 0, 10.0),
          child:  SizedBox(
            height: MediaQuery.of(context).size.height*1/16,
            child: TextField(
              onChanged: (text){
                setState(() {
                  if(text.isEmpty){
                    is_visible=false;
                  }
                  else{
                    is_visible=true;
                  }
                });
              },
              controller: textEditingController,
              decoration: InputDecoration(
                  hintText: '用户名/群聊名',
                  hintStyle: TextStyle(
                    fontSize: 15.0,
                  ),
                  isDense: true,
                  filled: true,
                  border: OutlineInputBorder(
                    borderSide: BorderSide(
                        color: Colors.white,
                        width: 2.5
                    ),
                    borderRadius: BorderRadius.all(const Radius.circular(5.0)),
                  ),
                  focusedBorder: OutlineInputBorder(
                    borderSide: BorderSide(
                        color: Colors.white,
                        width: 2.5
                    ),
                    borderRadius: BorderRadius.all(const Radius.circular(5.0)),
                  )
              ),
            ),
          ),
        ),
        actions: <Widget>[
          FlatButton(
            child: Text('搜索'),
            onPressed: () {
              //
            },
          )
        ],
      ),
      body:Visibility(
        visible: is_visible,
        child:  Column(
          children: <Widget>[
            Container(
              child:    ListTile(
                title: Text(
                  '找人: ' + textEditingController.text.toString(),
                  style: TextStyle(fontSize: 12.0),
                ),
                onTap: (){
                  Navigator.push(context,new MaterialPageRoute(builder: (context) => new add()));
                },
              ),
            ),
            Container(
              child:  ListTile(
                title: Text('找群: '+textEditingController.text.toString(),
                  style: TextStyle(
                      fontSize: 12.0
                  ),),
                onTap: (){
                  Navigator.push(context,new MaterialPageRoute(builder: (context) => new add()));
                },
              ) ,
            )
          ],
        ),
      ),
    );
  }
}
